﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace WPFTestDemo
{
    /// <summary>
    /// 表格单元格边框扩展。
    /// </summary>
    public static class TableCellBorderExtension
    {
        /// <summary>
        /// 订阅更新表格边框事件。
        /// </summary>
        /// <param name="element">订阅事件所属类型实例。</param>
        /// <param name="handler">订阅的事件委托。</param>
        public static void AddRefreshTableCellBorderHandler(UIElement element,
          EventHandler<RoutedEventArgs> handler)
        {
            element.AddHandler(RefreshTableCellBorderEvent, handler);
        }

        /// <summary>
        /// 移除更新表格边框事件。
        /// </summary>
        /// <param name="element">订阅事件所属类型实例。</param>
        /// <param name="handler">移除订阅的事件委托。</param>
        public static void RemoveRefreshTableCellBorderHandler(UIElement element,
            EventHandler<RoutedEventArgs> handler)
        {
            element.RemoveHandler(RefreshTableCellBorderEvent, handler);
        }

        /// <summary>
        /// 更新表格边框路由事件。
        /// </summary>
        public static readonly RoutedEvent RefreshTableCellBorderEvent =
            EventManager.RegisterRoutedEvent("RefreshTableCellBorder",
                RoutingStrategy.Bubble, typeof(EventHandler<RoutedEventArgs>),
                typeof(RoutedEventArgs));

        /// <summary>
        /// 引发表格单元格边框刷新路由事件。
        /// </summary>
        /// <param name="element">引发所属类型。</param>
        public static void RaiseRefreshTableCellBorderEvent(UIElement element)
        {
            element.RaiseEvent(new RoutedEventArgs(RefreshTableCellBorderEvent, element));
        }
    }
}
